package com.ywu.dev.admin.standard.dto;

import com.ywu.common.dto.CommonDto;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;

/**
 * @ClassName YwuDevOpsDto
 * @Description TODO
 * @Author GroundDemo
 * @Date 2024/11/24 12:36
 * @Version 1.0
 **/
@Data
@Slf4j
public class YwuDevOpsDto extends CommonDto {
    public static final String TEN_MINUTES = "TEN_MINUTES";

    public static final String TWENTY_MINUTES = "TWENTY_MINUTES";

    public static final String HALF_AN_HOUR = "HALF_AN_HOUR";

    public static final String ONE_HOUR = "ONE_HOUR";

    public static final String FIVE_HOUR = "FIVE_HOUR";

    public static final String TEN_HOUR = "TEN_HOUR";

    public static final String ONE_DAY = "ONE_DAY";

    public static final String TWO_DAY = "TWO_DAY";

    public static final String THREE_DAY = "THREE_DAY";

    public static final String SEVEN_DAY = "SEVEN_DAY";

    private String serviceName;

    private String serviceIpPort;

    private String searchTimeOver;

    public static String getSearchDataStr(String type) {
        LocalDateTime currentDate = LocalDateTime.now();
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss").withZone(ZoneId.of("Asia/Shanghai"));
        LocalDateTime resDate = currentDate;
        switch (type) {
            case TEN_MINUTES:
                resDate = currentDate.minusMinutes(10);
                break;
            case TWENTY_MINUTES:
                resDate = currentDate.minusMinutes(20);
                break;
            case HALF_AN_HOUR:
                resDate = currentDate.minusMinutes(30);
                break;
            case ONE_HOUR:
                resDate = currentDate.minusHours(1);
                break;
            case FIVE_HOUR:
                resDate = currentDate.minusHours(5);
                break;
            case ONE_DAY:
                resDate = currentDate.minusDays(1);
                break;
            case TWO_DAY:
                resDate = currentDate.minusDays(2);
                break;
            case THREE_DAY:
                resDate = currentDate.minusDays(3);
                break;
            case SEVEN_DAY:
                resDate = currentDate.minusDays(7);
                break;
        }
        String format = resDate.atZone(ZoneId.systemDefault()).format(formatter);
        log.debug("search date is {}", format);
        return format;
    }
}
